package org.zyl.springboot.mybatis.template.modules.msg.controller;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zyl.springboot.mybatis.template.e.GeneralConstant;
import org.zyl.support.response.ResponseCode;
import org.zyl.util.map.MapControl;

import net.sf.json.JSONObject;

@RestController
@RequestMapping("/msg")
public class MsgController {
	
	@Autowired
	private AmqpTemplate rabbitmqTemplate;
	
	@RequestMapping(name="/receive.html")
	public String receive(@RequestBody String body) {
		System.out.println(body);
		rabbitmqTemplate.convertAndSend(GeneralConstant.TOPIC_ZYL_MSG, body);
		return JSONObject.fromObject(MapControl.getControl().init_code(ResponseCode.SUCCESS).getMap()).toString();
	}
}